/*
 * @Description: 大前端学习
 * @Version: H5
 * @Author: Ajax
 * @Date: 2020-05-16 16:36:01
 * @LastEditors: Ajax
 * @LastEditTime: 2020-05-17 18:25:03
 */
; (function () {
    let animate = (obj, tagart, callBack) => {
        clearInterval(obj.move)
        obj.move = setInterval(() => {
            // console.log(obj.offsetLeft)
            let step = (tagart - obj.offsetLeft) / 10
            step = step > 0 ? Math.ceil(step) : Math.floor(step)

            obj.style.left = obj.offsetLeft + step + 'px'
            if (obj.offsetLeft == tagart) {
                obj.style.left = tagart + 'px'
                clearInterval(obj.move)
                callBack && callBack()
            }
        }, 15);
    }
    window.animate = animate
})()